package com.redis.filter.rebloom;

import io.rebloom.client.Client;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import java.util.*;

/**
 * 单服务
 */
public class clientDemo {

    public static void main(String[] args) {
        Client client = new Client(new JedisPool(new JedisPoolConfig(), "192.168.225.135",6379, 500, "123"));
        // 可以定制
        client.createFilter("specialBloom", 10000, 0.0001);

        Set<String> set = new HashSet<String>(1000);
        List<String> list = new ArrayList<String>(1000);
        for (int i = 0; i < 10000; i++) {
            String uuid = UUID.randomUUID().toString();
            if(i<1000){
                set.add(uuid);
                list.add(uuid);
            }
            client.add("simpleBloom", uuid);
        }

        for (int i = 0; i < 10; i++) {
            String uuid = UUID.randomUUID().toString();
            list.add(uuid);
        }

        System.out.println("------search--start--------");

        for (String k: list){
            System.out.println("-------------" + k + "--------------");
            System.out.println(client.exists("simpleBloom", k));
            System.out.println("-------------" + k + "--------------");
        }
    }
}
